package com.ftg.learn.bus.sharecar.controller;

import com.ftg.learn.bus.sharecar.pojo.sharecar;
import com.ftg.learn.bus.sharecar.service.sharecar_service;
import com.ftg.learn.bus.sharecar_userecord.pojo.sharecar_userecord_admin;
import com.ftg.learn.bus.util.ResultType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(value = "公车信息",tags = " 公车信息")
public class sharecar_controller {
    @Autowired
    sharecar_service ss;

    @GetMapping("/sharecar_query")
    @ApiOperation(value = "查询全部")
    public List<sharecar> query(){
        return ss.query();
    }

    @PostMapping("/sharecar_add")
    @ApiOperation(value = "添加")
    public int add(sharecar s){
        return ss.add(s);
    }

    @PutMapping("/sharecar_queryone/{car_name}")
    @ApiOperation(value = "查询一条")
    public sharecar queryone(@ApiParam("car_name") @PathVariable String car_name){
        return ss.queryone(car_name);
    }

    @PostMapping("/sharecar_update")
    @ApiOperation(value = "修改")
        public int update(sharecar s,String car_name){
        return ss.update(s,car_name);
    }

    @DeleteMapping("/sharecar_delete/{car_name}")
    @ApiOperation("删除")
    public int delete(@ApiParam("car_name") @PathVariable String car_name){
        return ss.delete(car_name);
    }

    @PutMapping("/writetoexcel/{url}")
    @ApiOperation("导出excel文件 ")
    public String writetoexcel(@ApiParam("路径") @PathVariable String url){
        return ss.exportExcel(url);
    }

    @PutMapping("/readtoexcel/{url}")
    @ApiOperation("导入excel文件 ")
    public String readtoexcel(@ApiParam("路径") @PathVariable String url){
        return ss.toLeadExcel(url);
    }
}
